﻿using Sinergija13.DataModel;
using System;
using System.Globalization;
using System.Text;

namespace Sinergija13.DataModel.Models.Conf
{
    public class Event
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime TimeBegin { get; set; }
        public DateTime TimeEnd { get; set; }
        public string Place { get; set; }
        public string Address { get; set; }
        public string Description { get; set; }
        public string Note { get; set; }
        public double Longitude { get; set; }
        public double Latitude { get; set; }
        public bool Visibility { get; set; }

        public override string ToString()
        {
            return String.Format("[{0}] {1} {2} {3}", Id, Name, TimeBegin, Place);
        }

        public string NameUppercase
        {
            get
            {
                return Name.ToUpper();
            }
        }

        public string DayName
        {
            // eg. ponedeljak
            get
            {
                return LocalizedDateHelper.GetDayNameForCulture(TimeBegin, "sr-Latn-CS");
            }
        }

        public string TimeBeginFullDateString
        {
            // eg. ponedeljak, 15. oktobar 2013.
            get
            {
                if (TimeBegin != default(DateTime))
                    return LocalizedDateHelper.GetFullDateForCulture(TimeBegin, "sr-Latn-CS");
                else
                    return String.Empty;
            }
        }

        public string TimeEndFullDateString
        {
            // eg. ponedeljak, 15. oktobar 2013.
            get
            {            
                if (TimeEnd != default(DateTime))
                    return LocalizedDateHelper.GetFullDateForCulture(TimeEnd, "sr-Latn-CS");
                else
                    return String.Empty;
            }
        }

        public string TimeSpanString
        {
            // eg. ponedeljak, 15. oktobar 2013. 22:00-00:00
            get
            {
                StringBuilder stringBuilder = new StringBuilder();
                if (TimeBegin != default(DateTime))
                    stringBuilder.AppendFormat("{0} {1}", TimeBeginFullDateString, LocalizedDateHelper.GetShortTimePatternForCulture(TimeBegin, "sr-Latn-CS"));
                else
                    return String.Empty;

                if (TimeEnd != default(DateTime))
                {
                    stringBuilder.AppendFormat("-{0}", LocalizedDateHelper.GetShortTimePatternForCulture(TimeEnd, "sr-Latn-CS"));
                }

                return stringBuilder.ToString(); 
            }
        }

        public string TimeSpanStringShort
        {
            // eg. 15. okt. 22:00-00:00
            get
            {
                StringBuilder stringBuilder = new StringBuilder();
                if (TimeBegin != default(DateTime))
                    stringBuilder.AppendFormat("{0} {1}", TimeBegin.ToString("dd. MMM", new CultureInfo("sr-Latn-CS")), LocalizedDateHelper.GetShortTimePatternForCulture(TimeBegin, "sr-Latn-CS"));
                else
                    return String.Empty;

                if (TimeEnd != default(DateTime))
                {
                    stringBuilder.AppendFormat("-{0}", LocalizedDateHelper.GetShortTimePatternForCulture(TimeEnd, "sr-Latn-CS"));
                }

                return stringBuilder.ToString(); 
            }
        }
    }
}
